package com.material.web.controller.pound;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.material.common.annotation.Log;
import com.material.common.core.controller.BaseController;
import com.material.common.core.domain.AjaxResult;
import com.material.common.enums.BusinessType;
import com.material.pound.domain.FuelPoundAssay;
import com.material.pound.service.IFuelPoundAssayService;
import com.material.common.utils.poi.ExcelUtil;
import com.material.common.core.page.TableDataInfo;

/**
 * 磅单化验明细Controller
 * 
 * @author ruoyi
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/pound/assay")
public class FuelPoundAssayController extends BaseController
{
    @Autowired
    private IFuelPoundAssayService fuelPoundAssayService;

    /**
     * 查询磅单化验明细列表
     */
    @PreAuthorize("@ss.hasPermi('pound:assay:list')")
    @GetMapping("/list")
    public TableDataInfo list(FuelPoundAssay fuelPoundAssay)
    {
        startPage();
        List<FuelPoundAssay> list = fuelPoundAssayService.selectFuelPoundAssayList(fuelPoundAssay);
        return getDataTable(list);
    }

    /**
     * 导出磅单化验明细列表
     */
    @PreAuthorize("@ss.hasPermi('pound:assay:export')")
    @Log(title = "磅单化验明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FuelPoundAssay fuelPoundAssay)
    {
        List<FuelPoundAssay> list = fuelPoundAssayService.selectFuelPoundAssayList(fuelPoundAssay);
        ExcelUtil<FuelPoundAssay> util = new ExcelUtil<FuelPoundAssay>(FuelPoundAssay.class);
        util.exportExcel(response, list, "磅单化验明细数据");
    }

    /**
     * 获取磅单化验明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('pound:assay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fuelPoundAssayService.selectFuelPoundAssayById(id));
    }

    /**
     * 新增磅单化验明细
     */
    @PreAuthorize("@ss.hasPermi('pound:assay:add')")
    @Log(title = "磅单化验明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FuelPoundAssay fuelPoundAssay)
    {
        return toAjax(fuelPoundAssayService.insertFuelPoundAssay(fuelPoundAssay));
    }

    /**
     * 修改磅单化验明细
     */
    @PreAuthorize("@ss.hasPermi('pound:assay:edit')")
    @Log(title = "磅单化验明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FuelPoundAssay fuelPoundAssay)
    {
        return toAjax(fuelPoundAssayService.updateFuelPoundAssay(fuelPoundAssay));
    }

    /**
     * 删除磅单化验明细
     */
    @PreAuthorize("@ss.hasPermi('pound:assay:remove')")
    @Log(title = "磅单化验明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fuelPoundAssayService.deleteFuelPoundAssayByIds(ids));
    }
}
